<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{$pagetitle}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/admin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/admin/style/admin.css" media="all">
</head>
<body>

	<div class="layui-fluid">
	<div class="layui-card">

	<div class="layui-form layui-card-header layuiadmin-card-header-auto">
	<div class="layui-form-item">


	  <div class="layui-inline">
		  <a class="layui-btn layuiadmin-btn-list iframe" href="{:url('add')}" data-type="add">添加用户</a>
	  </div>          
	</div>
	</div>

	<div class="layui-card-body">
	<form class="layui-form"  lay-filter="component-form-element">
	<table class="layui-table">
	  <colgroup>
		<col width="150">
		<col width="150">
		<col width="200">
		<col>
	  </colgroup>
	  <thead>
		<tr>
		  <th width="10%">ID</th>
		  <th>用户名</th>
		  <th>对应角色</th>
		  <th>登录次数</th>
		  <th>最后登录时间</th>
		  <th>最后登录IP</th>
		  <th>状态</th>
		  <th>查看日志</th>
		  <th>操作</th>
		</tr> 
	  </thead>
	  <tbody>
	  {foreach $data as $key=>$v}
		<tr>
		  <td style="text-align: center;">{$v.user_id}</td>
		  <td class="center tab-title">{$v.username}</td>
		  <td class="center">
			{if $v['user_id']==config('app.SUPER_ADMIN_USER_ID')}
				<span class="layui-badge layui-bg-green">超级管理员</span>             
			{else}
				{foreach $v['role'] as $role_rs}
					<span class="layui-badge layui-bg-black">{$role_rs.name}</span>
				{/foreach}                              
			{/if}
		  </td>
		  <td class="center">{$v.login_num}</td>                   
		  <td class="center"><?=$v['last_login_time']?date("Y-m-d",$v['last_login_time']):"-"?></td>
		  <td class="center">{$v['last_login_ip']?$v['last_login_ip']:"-"}</td>     
		  <td class="center">
			  <input type="checkbox" name="status" lay-filter="status" value="{$v.user_id}" lay-skin="switch" lay-text="开启|禁用" class="status" {$v["status"]?"checked":""}>			  
		  </td>   
		  <td class="center tab-title"><a href="{:url('UserLoginLog/index',array('userid'=>$v['user_id']))}">[登录日志]</a> &nbsp; <a href="{:url('UserLog/index',array('userid'=>$v['user_id']))}">[操作日志]</a></td> 
		  <td class="center">
			<a href="{:url('update',array('user_id'=>$v['user_id']))}" class="layui-btn layui-btn-sm iframe" title="修改页面"><i class="layui-icon">&#xe642;</i></a>
			<a href="{:url('delete',array('user_id'=>$v['user_id']))}" class="layui-btn layui-btn-sm ajax_del"><i class="layui-icon">&#xe640;</i></a>			  
		  </td>		  

		</tr>
  
	   {/foreach}
	  </tbody>
	</table>  
	</form>				  
	</div>
      
	</div>
</div>

  <script src="/static/admin/layui/layui.js"></script>
  <script src="/static/js/jquery.min.js"></script>    
  <script src="/static/js/globals.js"></script>  
  <script>
  layui.config({
    base: '/static/admin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
    var $ = layui.$
    ,admin = layui.admin
    ,element = layui.element
    ,form = layui.form;
    form.render(null, 'component-form-element');
    element.render('breadcrumb', 'breadcrumb');
    form.on('switch(status)', function(data){
      var checked=data.elem.checked;
	  var status=checked?1:0;
      var id=data.value;
      ajax_del("{:url('setStatus')}?id="+id+"&status="+status,function(msg,data){
		  layer.msg("设置成功");
	  });
    });

  });
  </script>

</body>
</html>
